<template>
	<view class="scroll-view_H">
		<tki-tree ref="tkitree" :selectParent="selectParent" :multiple="multiple"
		:range="treelist" :foldAll="flod" rangeKey="Name" :title="title" :showTree="showTreeValue"
		 @confirm="treeConfirm" @cancel="treeCancel" :selectvalue="selectvalue" @KeyInput="treekeyinput"></tki-tree>
		<popup-layer ref="popupRef" :direction="'left'">
			<view style="position:absolute;margin-left: 2%;margin-top:15rpx;" @tap="chaxunclose()">
				<image :src="srcfanhui" class="item-icon-sys" mode=""></image>
			</view>
			<view style="height: 93%;font-size: 30rpx;">
				<view class="box" style="text-align: center;">
					<view>筛选</view>
				</view>
				<view class="box">
					<view class="popupspan">资产编码:</view>
					<view class="popupinput"><input type="text" v-model="inputzcbm" placeholder="请输入资产编码" placeholder-class="inputff"/></view>
				</view>
				<view class="box">
					<view class="popupspan">资产名称:</view>
					<view class="popupinput"><input type="text" v-model="inputzcmc" placeholder="请输入资产名称" placeholder-class="inputff"/></view>
				</view>
				<view class="box">
					<view class="popupspan">资产类别:</view>
					<view class="popupinput">
						<view @tap="focusshow($event)" data-id="zclb" class="inputff">{{inputzclb}}</view>
						<!--<input type="text" v-model="inputzclb" placeholder="请输入资产类别" placeholder-class="inputff" @focus="focusshow($event)" data-Id="zclb"/>
				-->
				</view>
				</view>
				<view class="box">
					<view class="popupspan">管理部门:</view>
					<view class="popupinput">
						<!--<input type="text" v-model="inputglbm" placeholder="请输入管理部门" placeholder-class="inputff" @focus="focusshow($event)" data-Id="glbm"/>-->
					<view @tap="focusshow($event)" data-id="glbm" class="inputff">{{inputglbm}}</view>
					</view>
				</view>
				<view class="box">
					<view class="popupspan">责任人:</view>
					<view class="popupinput">
						<view @tap="focusshow($event)" data-id="zrr" class="inputff">{{inputzrr}}</view>
						<!--<input type="text" v-model="inputzrr" placeholder="请输入责任人" placeholder-class="inputff" @focus="focusshow($event)" data-Id="zrr"/>-->
						</view>
				</view>
				<view class="box">
					<view class="popupspan">使用部门:</view>
					<view class="popupinput">
						<view @tap="focusshow($event)" data-id="sybm" class="inputff">{{inputsybm}}</view>
						<!--<input type="text" v-model="inputsybm" placeholder="请输入使用部门" placeholder-class="inputff" @focus="focusshow($event)" data-Id="sybm"/>-->
						</view>
				</view>
				<view class="box">
					<view class="popupspan">使用人:</view>
					<view class="popupinput">
						<view @tap="focusshow($event)" data-id="syr" class="inputff">{{inputsyr}}</view>
						<!--<input type="text" v-model="inputsyr" placeholder="请输入使用人" placeholder-class="inputff" @focus="focusshow($event)" data-Id="syr"/>-->
						</view>
				</view>
					<view class="box">
						<view class="popupspan">资产位置:</view>
						<view class="popupinput">
							<!--<input type="text" v-model="inputglbm" placeholder="请输入管理部门" placeholder-class="inputff" @focus="focusshow($event)" data-Id="glbm"/>-->
							<view @tap="focusshow($event)" data-id="zcwz" class="inputff">{{inputzcwz}}</view>
						</view>
					</view>
			</view>
				<view class="box" style="border-bottom: 0px #bfbfbf solid;border-top: 1rpx #bfbfbf solid;padding-top: 5rpx;padding-bottom: 5rpx;">
					<view class="popupspan" style="width: 49.5%;text-align: center;border-right: 1px #bfbfbf solid;padding-left: 0rpx;font-size: 28rpx;" @tap="chaxunreset()">重置</view>
					<view class="popupinput" style="width: 49.5%;text-align: center;color: #6D8AF9;padding-right: 0rpx;" @tap="chaxunok()">确定</view>
				</view>
		        
				
		</popup-layer>
		<view style="height: 80rpx;background-color: #FFFFFF;">
			<view style="width:200rpx;font-size: 29rpx;height: 80rpx;line-height: 80rpx;color: #bfbfbf;">
				<view style="width: 300rpx;height: 80rpx;line-height: 80rpx;padding-left: 20rpx;">小计:{{SumCount}}</view>
			</view>
			
		</view>
		
		<view style="position:absolute;margin-left: 80%;margin-top:-60rpx;width: 120rpx;" @tap="sxchaxun()">
			<image :src="srcsys" class="item-icon-sys" style="float: left;" mode=""></image>
			<view style="float: left;font-size: 28rpx;color: #bfbfbf;">筛选</view>
		</view>
		
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :down="downOption" :up="upOption" @up="upCallback">
	<view class="" v-for="good in list" :key="good.id">
		<view class="Item">
			<view class="item-link item-content">
				<view class="item-inner" @tap="isanAsset(good)" :data-id="good.id">
					<view class="item-text">
						<view class="ispan" style="width: 97%;">
								<view style="background-color:#EA551B !important;float: left;width: 90rpx;text-align: center;color:#FFFFFF !important;padding: 0 15rpx;margin-right: 20rpx;border-radius:0rpx;">
								{{good.assetStatusId}}</view>
								<view style="float: left;font-weight:bold;color:#000000">{{good.name}}</view>
										
						</view>
						</view>
						<view class="item-text">
							<view  class="ispan">资产编码：</view>
							<view class="span">{{good.code}}</view>
							
						</view>
						
						<view class="item-text" style="width: 100%;">
							<view class="ispan"style="background-color: #E7F1FF;text-align: center;
							border-radius: 10rpx;
							color:#6D8AF9;height: 50rpx;line-height: 50rpx;font-weight: bold;">
							{{good.usingMenId}}</view>
							
							<view class="span">
							<view style="background-color: #E7F1FF;text-align: center;
							border-radius: 10rpx;
							color:#6D8AF9;height: 50rpx;line-height: 50rpx;font-weight: bold;
							padding:0 20rpx;float: left;
							">{{good.usingDepartmentId}}</view>
							</view>
						
						</view>
						<view class="item-line">
							
						</view>
					<view class="item-text">
					<view class="ispan">资产名称:</view><view class="span">{{good.name}}</view>
					</view>
					<view class="item-text">
					<view class="ispan">资产类别:</view><view class="span">{{good.assetCategoryId}}</view>
					</view>
					<view class="item-text">
					<view class="ispan">资产净值:</view><view class="span">{{good.netValue}}</view>
					</view>
					<view class="item-text">
					<view class="ispan">资产位置:</view><view class="span">{{good.storePlaceId}}</view>
					</view>
	
				</view>
				
			</view>
		</view>
	</view>
	</mescroll-body>
	
	
	</view>
	
</template>

<script>
	// 引入mescroll-mixins.js
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
	import popupLayer from "@/components/popup-layer/popup-layer.vue";
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
	import tkiTree from '@/components/tki-tree-asset/tki-tree.vue';
	import tabBar from '@/components/tabbar/tabbar1.vue'
	var self;
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
			MescrollBody
			,
			MescrollUni
			,
			popupLayer
			,
			tkiTree
			,
			tabBar
		},
		data() {
			return {
				// 下拉刷新的配置(可选, 绝大部分情况无需配置)
				downOption: {
					auto:true,
					native: false,
					beforeEndDownScroll:1000,
					textInOffset:"下拉刷新",
					textOutOffset:"释放刷新",
					textLoading:"加载中..."
				},upOption:{
					auto:true, // 不自动加载
					// page: {
					// 	num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
					// 	size: 10 // 每页数据的数量
					// },
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty:{
						tip: '~ 暂无数据 ~'
					},
					src: "../../static/images/totop.png",
					offset: 50,
					duration: 300,
					zIndex: 9990,
					right: 20,
					bottom: 120,
					safearea: false,
					width: 72,
					radius: "50%",
					left: null
				},
				list:[],
				loginName: "",
				SumCount:"0",
				srcsys: "../../static/images/icon-sxuan.png",
				srcfanhui: "../../static/images/icon-fanhui-you.png",
				inputgjz:"",
				inputzcbm:"",
				inputzcmc:"",
				inputzclb:"请选择资产类别 >",
				inputglbm:"请选择管理部门 >",
				inputzrr:"请选择责任人 >",
				inputsybm:"请选择使用部门 >",
				inputsyr:"请选择使用人 >",
					inputzcwz: "请选择资产位置 >",
					inputzcwzid: "",
				inputzclbid:"",
				inputglbmid:"",
				inputzrrid:"",
				inputsybmid:"",
				inputsyrid:"",	
				treelist: [],
				multiple: false,
				selectParent: true,
				flod: false,
				title:"选择资产类别",
				selectvalue:"",
				showTreeValue:false,
				ShowQueryValue:false,
				active: Number || 0,
				statuArray: ['全部','在用', '闲置', '借用','已报废'],
				statuindex:0,
				searchType:'all'
			}
		},
		onNavigationBarButtonTap(val) {
			//return;
			uni.navigateTo({
				url: '../stock/StockDocumentDetailSearch?Search=' + this.searchtext+"&Type=myasset",
			});
			
			
		    },
		onBackPress(options) {
			if(this.showTreeValue==true){
				this.showTreeValue=false;
				this.$refs.tkitree._hide();
				return true;
			}else{
				if(this.ShowQueryValue==true){
					this.ShowQueryValue=false;
					this.$refs.popupRef.close();
					return true;
				}else{
					
					//uni.navigateTo({
					//	url: '../home/Index',
					//});
					uni.setStorageSync('setStatusIndexFunc', 0);
					return false;
				}
			}			
		}, 
		methods: {
			/**
			 * @name 公共点击函数
			 * */
			_mainFuncInit(){
				this.active = uni.getStorageSync('setStatusIndexFunc') || 0
				//console.log(this.active)
				if(this.active==0){
					uni.navigateTo({
						url: '../home/Index',
					});	
				}else if(this.active==3){
					uni.navigateTo({
						url: '../home/home',
					});	
				}else if(this.active==4){
					uni.navigateTo({
						url: '../home/mysetup',
					});	
				}
			},
			/**
			 * @name 首页数据初始化 
			 * */
			_initData(){
				this._mainFuncInit();
			},
			/*下拉刷新的回调, 有三种处理方式:*/
			downCallback() {
				
				this.list=[];
				this.mescroll.resetUpScroll();
				
			},
			/*下拉加载的回调*/
			upCallback(page) {
				self = this;
				if (this.loginName == "") {
					const listdata = uni.getStorageSync("userinfo");
					self.loginName = listdata.LoginName;
				}
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				console.log(this.inputzcbm);
				let Assetstatusid="";
				
				let querydata={
						"pageSize": pageSize,
						"current": pageNum,
						"code":this.inputzcbm,
						"name":this.inputzcmc,
						"assetCategoryId":this.inputzclbid,
						"dutyDepartmentId":this.inputglbmid,
						"dutyMenId":this.inputzrrid,
						"usingDepartmentId":this.inputsybmid,
						"usingMenId":this.inputsyrid,
						"assetStatusId":this.statuindex==0?"":this.statuArray[this.statuindex],
						"storePlaceId":this.inputzcwzid==""?null:this.inputzcwzid,
						"excludeStatus":['delete'],
						showXuli:false,
					};
					if(self.searchType!="all"){
						if(self.searchType=="zy"){
							querydata["assetStatusId"]="inuse";
						}else if(self.searchType=="xz"){
							querydata["assetStatusId"]="idle";
						}else if(self.searchType=="jy"){
							querydata["assetStatusId"]="borrow";
						}else if(self.searchType=="ybf"){
							querydata["assetStatusId"]="scrap";
						}else if(self.searchType=="kc"){
							querydata["assetStatusId"]="store";
						}
					}
				
				this.request_tool({
					url:'/app/v1/asset/pageData',
					type:'POST',
					data:querydata
				}).then(res => {
					if (res.data.code == 2000) {
						var mydata = [];
						self.SumCount=res.data.data.totalAssetCount;						
						var newrows =res.data.data.records;
						for (var i = 0; i < newrows.length; i++) {
							
							var datarow = {};
							let newrow= newrows[i];
							datarow["Id"] = newrow["id"];
							datarow["assetStatusId"] = newrow.convertData["assetStatusId"];
							datarow["code"] = newrow["code"];						
							datarow["usingMenId"] = newrow.convertData["usingMenId"];
							datarow["usingDepartmentId"] = newrow.convertData["usingDepartmentId"];
							datarow["name"] = newrow["name"];
							datarow["assetCategoryId"] = newrow.convertData["assetCategoryId"];
							datarow["netValue"] = newrow["netValue"];
							datarow["storePlaceId"] = newrow.convertData["storePlaceId"];
							mydata.push(datarow);
							
						}
						//console.log(mydata);
						//this.productList = mydata;
						// 接口返回的当前页数据列表 (数组)
						let curPageData = mydata; 
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = mydata.length*10; 
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = res.data.total*10/page.size; 
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = res.data.total*10; 
						// 接口返回的是否有下一页 (true/false)
						let hasNext =false; 
						 //设置列表数据
						
						 if(page.num == 1) this.list = []; //如果是第一页需手动置空列表
						 this.list = this.list.concat(curPageData); //追加新数据
						 
						 // 请求成功,隐藏加载状态
						 //方法一(推荐): 后台接口有返回列表的总页数 totalPage
						 this.mescroll.endByPage(curPageLen, totalPage); 
						 
						 // 如果数据较复杂,可等到渲染完成之后再隐藏下拉加载状态: 如
						 // 建议使用setTimeout,因为this.$nextTick某些情况某些机型不触发
						 setTimeout(()=>{
						 	this.mescroll.endSuccess(curPageLen)
						 },20)
					
													 
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
				}).catch(err => {
				  console.error(err);
				  
				});
				
				
				// 此处仍可以继续写其他接口请求...
				// 调用其他方法...									
			},
			isanAsset(good){
				//console.log(e.currentTarget.dataset.id);
				uni.navigateTo({
					url: '../asset/asset?AssetCode=' + good.code,
				});
			},
			sxchaxun(){
				this.ShowQueryValue=true;
				 this.$refs.popupRef.show();
			},
			chaxunclose(){
				this.ShowQueryValue=false;
				this.$refs.popupRef.close();
			},
			chaxunreset(){
				this.inputzcbm="";
				this.inputzcmc="";
				this.inputzclb="请选择资产类别";
				this.inputglbm="请选择管理部门";
				this.inputzrr="请选择责任人";
				this.inputsybm="请选择使用部门";
				this.inputsyr="请选择使用人";
				this.inputzclbid="";
				this.inputglbmid="";
				this.inputzrrid="";
				this.inputsybmid="";
				this.inputsyrid="";
				
			},
			chaxunok(){
				this.ShowQueryValue=false;
				this.$refs.popupRef.close();
				this.downCallback();
			},
			focusshow(e){
				this.selectvalue=e.currentTarget.dataset.id;
				this.treelist=[];
				this.$refs.tkitree.oldtreeList="";
				this.$refs.tkitree.servalue="";
				
				if(e.currentTarget.dataset.id=="zclb"){
					this.showTree();
					this.title="请选择资产类别";
					this.loadAssetType();
				}else if(e.currentTarget.dataset.id=="glbm"){
					this.showTree();
					this.title="请选择管理部门";
					this.loadDepartment();
				}else if(e.currentTarget.dataset.id=="sybm"){
					this.showTree();
					this.title="请选择使用部门";
					this.loadDepartment();
				}else if(e.currentTarget.dataset.id=="zrr"){
					
					if(this.inputglbmid=="" || this.inputglbmid==null){
						uni.showToast({
							icon: 'none',
							title: '请选择管理部门'
						});
						return;
					}else{
						this.showTree();
						this.title="请选择责任人";
						this.loadglbmProfile();
					}
				}else if(e.currentTarget.dataset.id=="syr"){
					if(this.inputsybmid=="" || this.inputsybmid==null){
						uni.showToast({
							icon: 'none',
							title: '请选择使用部门'
						});
						return;
					}else{
						this.showTree();
						this.title="请选择使用人";
						this.loadsybmProfile();
					}
				}else if(e.currentTarget.dataset.id=="zcwz"){
					
					this.showTree();
					this.title="请选择资产位置";
					this.loadStoreplase();
				}
				
				
			},
			// 确定回调事件
			treeConfirm(e) {
				this.showTreeValue=false;
				if(this.selectvalue=="zclb"){
					this.inputzclb=e[0].label;
					this.inputzclbid=e[0].id;
				}else if(this.selectvalue=="glbm"){
					this.inputglbm=e[0].label;
					this.inputglbmid=e[0].id;
				}else if(this.selectvalue=="sybm"){
					this.inputsybm=e[0].label;
					this.inputsybmid=e[0].id;
				}else if(this.selectvalue=="zrr"){
					this.inputzrr=e[0].label;
					this.inputzrrid=e[0].id;
				}else if(this.selectvalue=="syr"){
					this.inputsyr=e[0].label;
					this.inputsyrid=e[0].id;
				}
				else if(this.selectvalue=="zcwz"){
					this.inputzcwz=e[0].label;
					this.inputzcwzid=e[0].id;
				}
			},
			// 取消回调事件
			treeCancel(e) {
				this.showTreeValue=false;
				console.log(e)
			},
			treekeyinput(value){
				let bmid="";
				if(this.selectvalue=="zrr"){
					bmid=this.inputglbmid;
				}
				if(this.selectvalue=="syr"){
					bmid=this.inputsybmid;
				}
				
				this.request_tool({
					url:'/app/v1/operator/pageData',
					type:'POST',
					data:{"orgId":bmid,"userName":value,"current":0,"pageSize":100}
				}).then(res => {
						//console.error(res);
						if(res!=undefined){
						if (res.data.code == 2000) {
							//console.log(res.data.data);
							//self.treelist= res.data.data;
							let newtreelist=[];
							for(var i=0;i<res.data.data.records.length;i++){
								let resitem= res.data.data.records[i];
								let treeitem={
									id:resitem.id,
									label:resitem.userName,
									isEnabled: resitem.isEnabled,
									checked:false,
									children:[],
								};
								newtreelist.push(treeitem);
							}
							self.treelist=newtreelist;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue=value;
							this.showTree();
							//this.model = res.data.model;
						}
						else{
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							});
						}
						}
						}).catch(err => {
				  console.error(err);
				  
				});
				
				//this.treelist=newtreeList;
			},
			// 显示树形选择器
			showTree() {
				this.showTreeValue=true;
				this.$refs.tkitree._show();
			},
			loadAssetType(){
				self=this;
				uni.showNavigationBarLoading();
				this.request_tool({
					url:'/app/v1/asset-category/treeData',
					type:'POST',
					data:{}
				}).then(res => {
						console.error(res);
						if (res.data.code == 2000) {
							console.log(res.data.data);
							self.treelist= res.data.data;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
						}).catch(err => {
				  console.error(err);
				  
				});
				
			},
			loadStoreplase() {
				self = this;
			
				uni.showNavigationBarLoading();
				let managePositionIds = uni.getStorageSync("managePositionIds");
				console.log(managePositionIds);
				this.request_tool({
					url:'/app/v1/position/treeData',
					type:'POST',
					data:{}
				}).then(res => {
						console.error(res);
						if (res.data.code == 2000) {
							let treedata= res.data.data;
							let newtreedata=[];
							self.filterParentNode(managePositionIds,treedata,newtreedata);
							self.treelist=newtreedata;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
						}).catch(err => {
				  console.error(err);
				  
				});
			
			},
			
			loadDepartment(){
				self=this;
				uni.showNavigationBarLoading();

				this.request_tool({
					url:'/app/v1/organization/treeData',
					type:'POST',
					data:{}
				}).then(res => {
						console.error(res);
						if (res.data.code == 2000) {
							console.log(res.data.data);
							self.treelist= res.data.data;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
						}).catch(err => {
				  console.error(err);
				  
				});
				/*
				uni.request({
					///v1/organization/treeData
					url:uni.getStorageSync("localurl")+'/Common/TreeSelector', //仅为示例，并非真实接口地址。
					data: {
						_Type: "AmsDepartments",
					},
					success: res2 => {
						if (res2.data.successed == true) {
							self.treelist= res2.data.data;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}
					},
					fail: () => {
						uni.hideNavigationBarLoading();
						uni.showToast({
							icon: 'none',
							title: '网络异常,请稍后重试'
						});
					}
				});
				*/
			},
			loadglbmProfile(){
				self=this;
							
				uni.showNavigationBarLoading();

				self.request_tool({
					url:'/app/v1/operator/pageData',
					type:'POST',
					data:{"orgId":self.inputglbmid,"current":0,"pageSize":100}
				}).then(res => {
						console.error(res);
						if(res!=undefined){
						if (res.data.code == 2000) {
							console.log(res.data.data);
							//self.treelist= res.data.data;
							let newtreelist=[];
							for(var i=0;i<res.data.data.records.length;i++){
								let resitem= res.data.data.records[i];
								let treeitem={
									id:resitem.id,
									label:resitem.userName,
									isEnabled: resitem.isEnabled,
									checked:false,
									children:[],
								};
								newtreelist.push(treeitem);
							}
							self.treelist=newtreelist;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
						}
						}).catch(err => {
				  console.error(err);
				  
				});
				
				
			},
			loadsybmProfile(){
				self=this;
				uni.showNavigationBarLoading();
				
				
				self.request_tool({
					url:'/app/v1/operator/pageData',
					type:'POST',
					data:{"orgId":self.inputsybmid,"current":0,"pageSize":100}
				}).then(res => {
						console.error(res);
						if(res!=undefined){
						if (res.data.code == 2000) {
							console.log(res.data.data);
							//self.treelist= res.data.data;
							let newtreelist=[];
							for(var i=0;i<res.data.data.records.length;i++){
								let resitem= res.data.data.records[i];
								let treeitem={
									id:resitem.id,
									label:resitem.userName,
									isEnabled: resitem.isEnabled,
									checked:false,
									children:[],
								};
								newtreelist.push(treeitem);
							}
							self.treelist=newtreelist;
							setTimeout(function () {
							  uni.hideNavigationBarLoading();
							}, 2000);
							this.$refs.tkitree.oldtreeList="";
							this.$refs.tkitree.servalue="";
							this.showTree();
							//this.model = res.data.model;
						}else{
								uni.showToast({
									icon: 'none',
									title: res.data.msg
								});
							}
						}
						}).catch(err => {
				  console.error(err);
				  
				});
				
			},
			bindPickerChange: function(e) {
			console.log(111);
				this.statuindex = e.target.value
			}
			,
			request_tool(options){
			 // 在这里可以对请求头进行一些设置
			 let baseUrl = uni.getStorageSync("localurl"); 
			 let userInfo = uni.getStorageSync("userInfo");
			 if (userInfo) {
			 	options.data['userLevelCode'] =JSON.parse(userInfo).levelCode;
			 	options.data['loginUserId'] = JSON.parse(userInfo).id;
			 }
			 let userDept = uni.getStorageSync("userDept");
			 //console.log(userDept);
			 if (userDept) {
			 	options.data['loginUserDeptLevelCode'] = userDept.levelCode;
			 	options.data['loginUserDeptId'] = userDept.id;
			 }
			 let currentRole = uni.getStorageSync("userRoles");
			 // console.log(currentRole);
			 if (currentRole) {
			 	options.data['roleLevelCode'] = currentRole[0].levelCode;
			 	options.data['roleId'] = currentRole[0].id;
			 }
			 let userReadDeptIds = uni.getStorageSync("userReadDeptIds");
			 
			 if (userReadDeptIds) {
			 	options.data['deptIds'] =userReadDeptIds;
			 }
			  options.header = {
			      'Content-Type':'application/json',
			      Authorization: uni.getStorageSync("authorization")
			 }
			
			    return new Promise((resolve, reject) => {
			        uni.request({
			            url: baseUrl + options.url || '',
			            method: options.type || 'POST',
			            data: options.data || {},
			            header: options.header || {}      
			        }).then(data => {
			            let [err, res] = data; 
						if(res.data.code==5001 || res.data.code==5002 ||
						res.data.code==5003 || res.data.code==5004){
							uni.removeStorageSync("LoginName");
							uni.removeStorageSync("userInfo");
							uni.removeStorageSync("authorization");
							uni.removeStorageSync("userToken")
							uni.removeStorageSync("userRoles");
							uni.removeStorageSync("userDept");
							uni.removeStorageSync("userReadDeptIds");
							uni.removeStorageSync("managePositionIds");
							uni.removeStorageSync("ASSETCODE");
							uni.navigateTo({
								url: '../login/login',
							});
						}
			            resolve(res);
			        }).catch(error => {
			            reject(error)
			        })
			    });
			},
			filterParentNode(ids,options,options2){
			      if(Array.isArray(ids)&&ids.length>0){
			        options.forEach(option=>{	
						if(ids.includes(option.id)){
							let newoption={
								"id": option.id,
								"code": option.code,
								"label": option.label,
								"isEnabled": option.isEnabled,
								"levelCode": option.levelCode,
								"parentLevelCode": option.parentLevelCode,
								"pathCode": option.pathCode,
								"entityName": option.entityName,
							}							
							let childrenarr=[];
							if(option.children){
							  this.filterParentNode(ids,option.children,childrenarr);
							}
							newoption.children=childrenarr;
							
							options2.push(newoption);
						}else{							
							if(option.children){
								let childrenarr=[];
							  this.filterParentNode(ids,option.children,childrenarr);
							  if(childrenarr.length>0){
								  let newoption={
								  	"id": option.id,
								  	"code": option.code,
								  	"label": option.label,
								  	"isEnabled": "0",
								  	"levelCode": option.levelCode,
								  	"parentLevelCode": option.parentLevelCode,
								  	"pathCode": option.pathCode,
								  	"entityName": option.entityName,
								  }
									newoption.children=childrenarr;
									options2.push(newoption);
							  }
							}
						}
			         
			        });
			      }
			    },
			
			
		},
		onLoad(options) {
			//首先将实例指针保存到全局变量 self 方便在异步请求中访问实例本身
			self = this;
		
			
			uni.getStorage({
				key: 'userinfo',
				success: function(newres) {
					const listdata = newres.data;
					self.loginName = listdata.LoginName;
				}
			});
			console.log((options.searchType));
			this.searchType=options.searchType;
		
		
		},
		provide(){
			return {
				_mainFuncInit: this._mainFuncInit
			}
		},
		onShow(){
			
			
		}
	}
</script>

<style>
	.item-icon-sys {
		width: 40upx;
		height: 40upx;
	}
.scroll-view_H{
		background-color: #edf1f4;
		padding-left: 10px;
		padding-right: 10px;
	}
	.Item {
		border: 1px solid #e6e6e6;
		overflow: hidden;
		padding-bottom: 16rpx;
		border-radius: 16rpx;
		background: #fff;
		margin-top: 10rpx;
	}
	
	.item-text .span {
		display: inline-block;
		width: 72%;
		float: right;
	}
	
	.item-text .ispan {
		font-style: normal;
		width: 25%;
		display: inline-block;
		color: #9E9CA5;
	}
	
	.item-content {
		padding-left: 0;
	}
	
	.item-title .ispan {
		font-size: 30rpx;
		width: auto;
		height: auto;
	}
	
	.item-title {
		font-size: 40rpx;
		color: #454545;
		width: 100%;
	}
	
	.item-title-row {
		background-image: none;
		padding-right: 0px;
	}
	
	.item-link .item-inner {
		padding-right: 0;
	}
	.item-text {
		font-size: 30rpx;
		color: #454545;
		margin: 20rpx 0;
		padding-left: 20rpx;
		line-height: 1.2;
	}
	
	.box{
		width: 600rpx;border-bottom: 1px #CCCCCC solid;
		height: 80rpx;
		line-height: 80rpx;
	}
	.box .popupspan{
		width: 36.5%;display: inline-block;height: 80rpx;
		line-height: 80rpx;
		padding-left: 3.5%;
		color: #5a5a5a;
	}
	.box .popupinput{
		width: 52%;text-align: right;display: inline-block;height: 80rpx;line-height: 80rpx;
		padding-right: 30rpx;
		float: right;
	}
	.box .popupinput input{	
		height: 100%;line-height: 100%;
	}
	.inputff{
			color: #BEBEBE;
			font-size:30rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.box .popupinput{
			font-size:30rpx;
			}
			// 选中tab的线
			.item-line{
				z-index: 1;
				
				bottom: 30rpx; // 至少与.tabs-item的padding-bottom一致,才能保证在底部边缘
				width: 1800rpx;
				height: 0.1rpx;
				transform: translateX(-50%);
				border-radius: 4rpx;
				transition: left .3s;
				background: #EFEFEF;
			}
</style>
